import { Button } from 'antd';
import {WeaDialog ,WeaNewScroll,WeaSearchGroup,WeaLocaleProvider,WeaTab,WeaFormItem,WeaTableEdit} from 'ecCom';
import {observer} from "mobx-react";
import {toJS} from 'mobx';
import {WeaTableNew} from 'comsMobx';
const WeaTable = WeaTableNew.WeaTable;
const getLabel = WeaLocaleProvider.getLabel;

@observer
class LanmuEditDialog extends React.Component {
    constructor(props) {
        super(props);
    }

    shouldComponentUpdate(nextProps,nextState){
        return true;
    }
 
    render() {
        const { store } = this.props;
        const { visible, setVisible, defColumns, columnDatas } = store;
        return (
            <div>
            <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@sxyh38`}
                title={'栏目编辑'}
                visible={visible}
                buttons={this.getButtons()}
                icon="icon-coms-ModelingEngine"
                iconBgcolor="#217346"
                onCancel={()=>{setVisible(false)}}
                style={{width:'1000px', height:'600px'}}
            >
                <WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@as008c`} height={"100%"}>
                    <WeaTableEdit ecId={`${this && this.props && this.props.ecId || ''}_WeaTableEdit@ocqr2y`}
                        isModalEdit={false}
                        columns={toJS(defColumns)}
                        datas={toJS(columnDatas)}
                        onChange={this.onChange}
                        ref="tableEdit"
                        rowKey={"id"}
                        showCopy={false}
                        draggable={true}
                        showDelete={true}
                        showAdd={true}
                        rowSelection={{}}
                        copyFilterProps={["id"]}
                    />
                </WeaNewScroll>
            </WeaDialog>
        </div>)
    }

    onChange = (datas) => {
        const { store } = this.props;
        const { setColumnDatas } = store;
        setColumnDatas(datas);
    }

    getButtons(){
        const { store } = this.props;
        const { setVisible, submitDatas } = store;
        let btnArr = []; 
        btnArr.push(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@fjjgvg@close`}  type="primary" onClick={()=>{
            if(this.refs.tableEdit.refs.edit.doRequiredCheck().pass){
                submitDatas();
            }
        }}>{getLabel(615,"提交")}</Button>)  
        btnArr.push(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@fjjgvg@close`}  type="primary" onClick={()=>setVisible(false)}>{getLabel(309,"关闭")}</Button>)  
        return btnArr;
    }
   
}

export default LanmuEditDialog;